
import 'dart:convert';

import 'package:shared_preferences/shared_preferences.dart';

const keyUser = 'USER';

class PrefsUtils {
  static void saveJSON(String key, Map<String, dynamic> json) async {
    final prefs = await SharedPreferences.getInstance();
    await prefs.setString(key, jsonEncode(json));
  }
  static Future<dynamic> fromJSON(String key) async {
    final prefs = await SharedPreferences.getInstance();
    final userStr = prefs.getString(key);
    if (userStr == null) {
      return null;
    }
    return jsonDecode(userStr);
  }
}
